<div class="hbox hbox-auto-xs hbox-auto-sm" ng-init="
    app.settings.asideFolded = false;
    app.settings.asideDock = false;
  ">
    <!-- main -->
    <div class="col">
        <!-- main header -->
        <div class="bg-light lter b-b wrapper-md">
            <div class="row">
                <div class="col-sm-6 col-xs-12">
                    <h1 class="m-n font-thin h3 text-black">用户管理(LDAP)</h1>
                    <!--<small class="text-muted">可访问堡垒机列表管理</small>-->
                </div>
            </div>
        </div>
        <!-- / main header -->
        <div class="wrapper-md">
            <!-- toaster directive -->
            <toaster-container
                    toaster-options="{'position-class': 'toast-top-right', 'close-button':true}"></toaster-container>
            <!-- / toaster directive -->

            <uib-tabset>
                <div ng-controller="usersCtrl">
                    <div style="margin-top: 5px;" class="panel panel-default">
                        <div class="panel-body">
                            <form class="form-inline" role="form">
                                <div class="form-group">
                                    <div class="input-group">
                                        <span class="input-group-addon">用户</span>
                                        <input type="text" class="form-control" ng-model="username"
                                               placeholder="用户名">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <button type="button" class="btn btn-info" ng-click="doQuery()"><span
                                            class="glyphicon glyphicon-search"></span>搜索
                                    </button>
                                </div>
                                <div class="form-group">
                                    <button type="button" class="btn btn-success" ng-click="addUser()"
                                            ng-if="contains(authPoint, '/users/save')">
                                        <span class="glyphicon glyphicon-plus"></span>新建用户
                                    </button>
                                </div>
                                <!--<div class="form-group">-->
                                <!--<button type="button" class="btn btn-success" ng-click="addUsersMobile()">-->
                                <!--<span class="fa fa-circle-o-notch"></span>填充手机号-->
                                <!--</button>-->
                                <!--</div>-->
                            </form>
                            <div style="margin-top: 5px;">
                                <table class="table table-hover table-bordered table-striped">
                                    <thead>
                                    <tr>
                                        <td>用户信息</td>
                                        <td>角色</td>
                                        <td>基本权限</td>
                                        <td>LDAP组</td>
                                        <td>更新时间</td>
                                        <td ng-if="contains(authPoint, '/users/save')">操作</td>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr ng-repeat="item in pageData">
                                        <!--用户信息-->
                                        <td>
                                            {{item.username}}</br>
                                            <b>{{item.displayName}}</b>
                                            </br>
                                            <!--<span class="label label-success" ng-if="item.mailAccountStatus == 'active'">Active</span>-->
                                            <b style="color: #286090"> {{item.mail}}</b>
                                            </br>
                                            <b class="fa fa-phone"></b>
                                            <b ng-show="item.mobile != ''">{{item.mobile}}</b>
                                            <!--<span class="fa fa-circle-o-notch"-->
                                            <!--uib-popover-html="'填充手机号'" popover-trigger="'mouseenter'"-->
                                            <!--ng-click="addUserMobile(item.id)"></span>-->
                                        </td>
                                        <td>
                                            <div ng-repeat="role in item.roleDOList">
                                                <i class="icon icon-badge" style="color: #d9534f"
                                                   ng-if="role.roleName == 'admin'"></i>
                                                <b style="color: #286090">{{role.roleName}}</b>
                                                <b class="pull-right" style="color: #777">{{role.roleDesc}}</b>
                                            </div>
                                        </td>
                                        <!--<td>{{item.authed == 0 ? "未授权" : "已授权"}}</td>-->
                                        <td>
                                            <b style="color: #449d44" ng-if="item.authed != 0">已授权</b>
                                            <b style="color: #777" ng-if="item.authed == 0">未授权</b>
                                            <b class="pull-right" style="color: #777">堡垒机</b>
                                            </br>
                                            <b style="color: #449d44" ng-if="item.ldap != 0">已绑定</b>
                                            <b style="color: #777" ng-if="item.ldap == 0">未绑定</b>
                                            <b class="pull-right" style="color: #777">LDAP</b>
                                        </td>
                                        <td>
                                            <!--<div class="col-md-12" ng-repeat="ldapGroup in item.ldapGroups">{{ldapGroup}}</div>-->
                                            <div ng-repeat="ldapGroup in item.ldapGroups">
                                                <b ng-show="ldapGroup.bind"
                                                   style="color: #449d44">{{ldapGroup.name}}</b>
                                            </div>
                                        </td>
                                        <td>{{item.gmtCreate}}</td>
                                        <td ng-if="contains(authPoint, '/users/save')">
                                            <button ng-click="userLdapInfo(item)"
                                                    class="btn btn-xs"
                                                    style="margin-left: 5px; background-color: #2e6da4; color: white;">
                                                <span class="glyphicon glyphicon-edit"></span>编辑
                                            </button>
                                            <!--<span class="glyphicon glyphicon-pencil pull-left"-->
                                            <!--ng-click="userLdapInfo(item)">-->
                                            <!--</span>-->
                                            <button ng-click="serverList(item.username)"
                                                    class="btn btn-xs"
                                                    uib-popover-html="'授权服务器组列表'" popover-trigger="'mouseenter'"
                                                    style="margin-left: 5px; background-color: #2e6da4; color: white;">
                                                <span class="glyphicon glyphicon-edit"></span>授权组信息
                                            </button>

                                            <!--<span class="glyphicon glyphicon-list" style="margin-left: 20px;"-->
                                            <!--uib-popover-html="'授权服务器组'" popover-trigger="'mouseenter'"-->
                                            <!--ng-click="serverList(item.username)">-->
                                            <!--</span>-->

                                            <button ng-click="userLeave(item.username)"
                                                    class="btn btn-xs pull-right"
                                                    style="background-color: red; color: white;">
                                                <span class="icon icon-user-unfollow"></span>离职
                                            </button>

                                            <!--<span class="icon icon-user-unfollow pull-right" style="color: #d9534f"-->
                                            <!--ng-click="userLeave(item.username)"></span>-->
                                        </td>
                                    </tr>
                                    </tbody>
                                    <tfoot>
                                    <tr>
                                        <td colspan="10">
                                            <ul style="margin: 0px; float: right;" uib-pagination
                                                total-items="totalItems" ng-model="currentPage"
                                                items-per-page="pageLength" max-size="10" ng-change="pageChanged()"
                                                previous-text="&lsaquo;" next-text="&rsaquo;"></ul>
                                        </td>
                                    </tr>
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </uib-tabset>
        </div>
    </div>
    <!-- / main -->
</div>

<script type="text/ng-template" id="userLdapInfo">
    <div ng-include="'tpl/modal/user/user_ldap_info_modal.html'"></div>
</script>

<script type="text/ng-template" id="keyBoxServerModal">
    <div ng-include="'tpl/modal/keybox/keybox_server_modal.html'"></div>
</script>

<script type="text/ng-template" id="userInfo">
    <div ng-include="'tpl/modal/user/user_info_modal.html'"></div>
</script>